
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Control Loading · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="downfile.html" />
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="./">
            
                <a href="./">
            
                    
                    前端进阶
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="Grid System.html">
            
                <a href="Grid System.html">
            
                    
                    Grid System
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="Handwritten signature.html">
            
                <a href="Handwritten signature.html">
            
                    
                    Handwritten Signature
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="Mobile Soft Keyboard.html">
            
                <a href="Mobile Soft Keyboard.html">
            
                    
                    Mobile Soft Keyboard
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="authentication.html">
            
                <a href="authentication.html">
            
                    
                    Authentication
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" >
            
                <span>
            
                    
                    Code
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" >
            
                <span>
            
                    
                    Four Operations
            
                </span>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter active" data-level="1.8" data-path="control loading.html">
            
                <a href="control loading.html">
            
                    
                    Control Loading
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="downfile.html">
            
                <a href="downfile.html">
            
                    
                    Downfile
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="dynamic-routing.html">
            
                <a href="dynamic-routing.html">
            
                    
                    Dynamic Routing
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="ecs.html">
            
                <a href="ecs.html">
            
                    
                    Ecs
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="engineering.html">
            
                <a href="engineering.html">
            
                    
                    Engineering
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="eslint-vscode-format.html">
            
                <a href="eslint-vscode-format.html">
            
                    
                    Eslint Vscode Format
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="eventloop.html">
            
                <a href="eventloop.html">
            
                    
                    Eventloop
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="four-operations-1.html">
            
                <a href="four-operations-1.html">
            
                    
                    Four Operations 1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="four-operations-2.html">
            
                <a href="four-operations-2.html">
            
                    
                    Four Operations 2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="four-operations-3.html">
            
                <a href="four-operations-3.html">
            
                    
                    Four Operations 3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="four-operations-4.html">
            
                <a href="four-operations-4.html">
            
                    
                    Four Operations 4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="front end summary.html">
            
                <a href="front end summary.html">
            
                    
                    Front End Summary
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="git commit style.html">
            
                <a href="git commit style.html">
            
                    
                    Git Commit Style
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="git-commands.html">
            
                <a href="git-commands.html">
            
                    
                    Git Commands
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.22" data-path="high-quality-code.html">
            
                <a href="high-quality-code.html">
            
                    
                    High Quality Code
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.23" data-path="history.html">
            
                <a href="history.html">
            
                    
                    History
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.24" data-path="html-tag.html">
            
                <a href="html-tag.html">
            
                    
                    Html Tag
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.25" data-path="http-https-http2.html">
            
                <a href="http-https-http2.html">
            
                    
                    Http Https Http2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.26" data-path="ignore log.html">
            
                <a href="ignore log.html">
            
                    
                    Ignore Log
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.27" >
            
                <span>
            
                    
                    Imgs
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.28" data-path="javascript-optimization.html">
            
                <a href="javascript-optimization.html">
            
                    
                    Javascript Optimization
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.29" data-path="local application.html">
            
                <a href="local application.html">
            
                    
                    Local Application
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.30" data-path="locality.html">
            
                <a href="locality.html">
            
                    
                    Locality
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.31" data-path="loop-unrolling.html">
            
                <a href="loop-unrolling.html">
            
                    
                    Loop Unrolling
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.32" data-path="mobile recommendation.html">
            
                <a href="mobile recommendation.html">
            
                    
                    Mobile Recommendation
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.33" data-path="modal.html">
            
                <a href="modal.html">
            
                    
                    Modal
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.34" data-path="monitor.html">
            
                <a href="monitor.html">
            
                    
                    Monitor
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.35" data-path="performance.html">
            
                <a href="performance.html">
            
                    
                    Performance
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.36" data-path="print-talbe.html">
            
                <a href="print-talbe.html">
            
                    
                    Print Talbe
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.37" data-path="promise.html">
            
                <a href="promise.html">
            
                    
                    Promise
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.38" data-path="teaching.html">
            
                <a href="teaching.html">
            
                    
                    Teaching
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.39" data-path="vue refresh.html">
            
                <a href="vue refresh.html">
            
                    
                    Vue Refresh
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.40" data-path="vue-page-not-refresh.html">
            
                <a href="vue-page-not-refresh.html">
            
                    
                    Vue Page Not Refresh
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.41" data-path="why-learn-theory.html">
            
                <a href="why-learn-theory.html">
            
                    
                    Why Learn Theory
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >Control Loading</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x591A;&#x4E2A;&#x8BF7;&#x6C42;&#x4E0B;-loading-&#x7684;&#x5C55;&#x793A;&#x4E0E;&#x5173;&#x95ED;">&#x591A;&#x4E2A;&#x8BF7;&#x6C42;&#x4E0B; loading &#x7684;&#x5C55;&#x793A;&#x4E0E;&#x5173;&#x95ED;</h1>
<p>&#x4E00;&#x822C;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x5728; vue &#x4E2D;&#x7ED3;&#x5408; axios &#x7684;&#x62E6;&#x622A;&#x5668;&#x63A7;&#x5236; loading &#x5C55;&#x793A;&#x548C;&#x5173;&#x95ED;&#xFF0C;&#x662F;&#x8FD9;&#x6837;&#x7684;&#xFF1A;
&#x5728; <code>App.vue</code> &#x914D;&#x7F6E;&#x4E00;&#x4E2A;&#x5168;&#x5C40; loading&#x3002;</p>
<pre><code class="lang-html">    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;app&quot;</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">keep-alive</span> <span class="hljs-attr">:include</span>=<span class="hljs-string">&quot;keepAliveData&quot;</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">router-view</span>/&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">keep-alive</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;loading&quot;</span> <span class="hljs-attr">v-show</span>=<span class="hljs-string">&quot;isShowLoading&quot;</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">Spin</span> <span class="hljs-attr">size</span>=<span class="hljs-string">&quot;large&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">Spin</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>&#x540C;&#x65F6;&#x8BBE;&#x7F6E; axios &#x62E6;&#x622A;&#x5668;&#x3002;</p>
<pre><code class="lang-js"> <span class="hljs-comment">// &#x6DFB;&#x52A0;&#x8BF7;&#x6C42;&#x62E6;&#x622A;&#x5668;</span>
 <span class="hljs-keyword">this</span>.$axios.interceptors.request.use(config =&gt; {
     <span class="hljs-keyword">this</span>.isShowLoading = <span class="hljs-literal">true</span>
     <span class="hljs-keyword">return</span> config
 }, error =&gt; {
     <span class="hljs-keyword">this</span>.isShowLoading = <span class="hljs-literal">false</span>
     <span class="hljs-keyword">return</span> <span class="hljs-built_in">Promise</span>.reject(error)
 })

 <span class="hljs-comment">// &#x6DFB;&#x52A0;&#x54CD;&#x5E94;&#x62E6;&#x622A;&#x5668;</span>
 <span class="hljs-keyword">this</span>.$axios.interceptors.response.use(response =&gt; {
     <span class="hljs-keyword">this</span>.isShowLoading = <span class="hljs-literal">false</span>
     <span class="hljs-keyword">return</span> response
 }, error =&gt; {
     <span class="hljs-keyword">this</span>.isShowLoading = <span class="hljs-literal">false</span>
     <span class="hljs-keyword">return</span> <span class="hljs-built_in">Promise</span>.reject(error)
 })
</code></pre>
<p>&#x8FD9;&#x4E2A;&#x62E6;&#x622A;&#x5668;&#x7684;&#x529F;&#x80FD;&#x662F;&#x5728;&#x8BF7;&#x6C42;&#x524D;&#x6253;&#x5F00; loading&#xFF0C;&#x8BF7;&#x6C42;&#x7ED3;&#x675F;&#x6216;&#x51FA;&#x9519;&#x65F6;&#x5173;&#x95ED; loading&#x3002;
&#x5982;&#x679C;&#x6BCF;&#x6B21;&#x53EA;&#x6709;&#x4E00;&#x4E2A;&#x8BF7;&#x6C42;&#xFF0C;&#x8FD9;&#x6837;&#x8FD0;&#x884C;&#x662F;&#x6CA1;&#x95EE;&#x9898;&#x7684;&#x3002;&#x4F46;&#x540C;&#x65F6;&#x6709;&#x591A;&#x4E2A;&#x8BF7;&#x6C42;&#x5E76;&#x53D1;&#xFF0C;&#x5C31;&#x4F1A;&#x6709;&#x95EE;&#x9898;&#x4E86;&#x3002;</p>
<p><strong>&#x4E3E;&#x4F8B;</strong>&#xFF1A;</p>
<p>&#x5047;&#x5982;&#x73B0;&#x5728;&#x540C;&#x65F6;&#x53D1;&#x8D77;&#x4E24;&#x4E2A;&#x8BF7;&#x6C42;&#xFF0C;&#x5728;&#x8BF7;&#x6C42;&#x524D;&#xFF0C;&#x62E6;&#x622A;&#x5668; <code>this.isShowLoading = true</code> &#x5C06; loading &#x6253;&#x5F00;&#x3002;
&#x73B0;&#x5728;&#x6709;&#x4E00;&#x4E2A;&#x8BF7;&#x6C42;&#x7ED3;&#x675F;&#x4E86;&#x3002;<code>this.isShowLoading = false</code> &#x62E6;&#x622A;&#x5668;&#x5173;&#x95ED; loading&#xFF0C;&#x4F46;&#x662F;&#x53E6;&#x4E00;&#x4E2A;&#x8BF7;&#x6C42;&#x7531;&#x4E8E;&#x67D0;&#x4E9B;&#x539F;&#x56E0;&#x5E76;&#x6CA1;&#x6709;&#x7ED3;&#x675F;&#x3002;
&#x9020;&#x6210;&#x7684;&#x540E;&#x679C;&#x5C31;&#x662F;&#x9875;&#x9762;&#x8BF7;&#x6C42;&#x8FD8;&#x6CA1;&#x5B8C;&#x6210;&#xFF0C;loading &#x5374;&#x5173;&#x95ED;&#x4E86;&#xFF0C;&#x7528;&#x6237;&#x4F1A;&#x4EE5;&#x4E3A;&#x9875;&#x9762;&#x52A0;&#x8F7D;&#x5B8C;&#x6210;&#x4E86;&#xFF0C;&#x7ED3;&#x679C;&#x9875;&#x9762;&#x4E0D;&#x80FD;&#x6B63;&#x5E38;&#x8FD0;&#x884C;&#xFF0C;&#x5BFC;&#x81F4;&#x7528;&#x6237;&#x4F53;&#x9A8C;&#x4E0D;&#x597D;&#x3002;</p>
<p><strong>&#x89E3;&#x51B3;&#x65B9;&#x6848;</strong>
&#x589E;&#x52A0;&#x4E00;&#x4E2A; <code>loadingCount</code> &#x53D8;&#x91CF;&#xFF0C;&#x7528;&#x6765;&#x8BA1;&#x7B97;&#x8BF7;&#x6C42;&#x7684;&#x6B21;&#x6570;&#x3002;</p>
<pre><code class="lang-js">loadingCount: <span class="hljs-number">0</span>
</code></pre>
<p>&#x518D;&#x589E;&#x52A0;&#x4E24;&#x4E2A;&#x65B9;&#x6CD5;&#xFF0C;&#x6765;&#x5BF9; <code>loadingCount</code>  &#x8FDB;&#x884C;&#x589E;&#x51CF;&#x64CD;&#x4F5C;&#x3002;</p>
<pre><code class="lang-js">    methods: {
        addLoading() {
            <span class="hljs-keyword">this</span>.isShowLoading = <span class="hljs-literal">true</span>
            <span class="hljs-keyword">this</span>.loadingCount++
        },

        isCloseLoading() {
            <span class="hljs-keyword">this</span>.loadingCount--
            <span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>.loadingCount == <span class="hljs-number">0</span>) {
                <span class="hljs-keyword">this</span>.isShowLoading = <span class="hljs-literal">false</span>
            }
        }
    }
</code></pre>
<p>&#x73B0;&#x5728;&#x62E6;&#x622A;&#x5668;&#x53D8;&#x6210;&#x8FD9;&#x6837;&#xFF1A;</p>
<pre><code class="lang-js">        <span class="hljs-comment">// &#x6DFB;&#x52A0;&#x8BF7;&#x6C42;&#x62E6;&#x622A;&#x5668;</span>
        <span class="hljs-keyword">this</span>.$axios.interceptors.request.use(config =&gt; {
            <span class="hljs-keyword">this</span>.addLoading()
            <span class="hljs-keyword">return</span> config
        }, error =&gt; {
            <span class="hljs-keyword">this</span>.isShowLoading = <span class="hljs-literal">false</span>
            <span class="hljs-keyword">this</span>.loadingCount = <span class="hljs-number">0</span>
            <span class="hljs-keyword">this</span>.$Message.error(<span class="hljs-string">&apos;&#x7F51;&#x7EDC;&#x5F02;&#x5E38;&#xFF0C;&#x8BF7;&#x7A0D;&#x540E;&#x518D;&#x8BD5;&apos;</span>)
            <span class="hljs-keyword">return</span> <span class="hljs-built_in">Promise</span>.reject(error)
        })

        <span class="hljs-comment">// &#x6DFB;&#x52A0;&#x54CD;&#x5E94;&#x62E6;&#x622A;&#x5668;</span>
        <span class="hljs-keyword">this</span>.$axios.interceptors.response.use(response =&gt; {
            <span class="hljs-keyword">this</span>.isCloseLoading()
            <span class="hljs-keyword">return</span> response
        }, error =&gt; {
            <span class="hljs-keyword">this</span>.isShowLoading = <span class="hljs-literal">false</span>
            <span class="hljs-keyword">this</span>.loadingCount = <span class="hljs-number">0</span>
            <span class="hljs-keyword">this</span>.$Message.error(<span class="hljs-string">&apos;&#x7F51;&#x7EDC;&#x5F02;&#x5E38;&#xFF0C;&#x8BF7;&#x7A0D;&#x540E;&#x518D;&#x8BD5;&apos;</span>)
            <span class="hljs-keyword">return</span> <span class="hljs-built_in">Promise</span>.reject(error)
        })
</code></pre>
<p>  &#x8FD9;&#x4E2A;&#x62E6;&#x622A;&#x5668;&#x7684;&#x529F;&#x80FD;&#x662F;&#xFF1A;
  &#x6BCF;&#x5F53;&#x53D1;&#x8D77;&#x4E00;&#x4E2A;&#x8BF7;&#x6C42;&#xFF0C;&#x6253;&#x5F00; loading&#xFF0C;&#x540C;&#x65F6; <code>loadingCount</code> &#x52A0;1&#x3002;
  &#x6BCF;&#x5F53;&#x4E00;&#x4E2A;&#x8BF7;&#x6C42;&#x7ED3;&#x675F;&#xFF0C; <code>loadingCount</code> &#x51CF;1&#xFF0C;&#x5E76;&#x5224;&#x65AD;  <code>loadingCount</code> &#x662F;&#x5426;&#x4E3A; 0&#xFF0C;&#x5982;&#x679C;&#x4E3A; 0&#xFF0C;&#x5219;&#x5173;&#x95ED; loading&#x3002;
&#x8FD9;&#x6837;&#x5373;&#x53EF;&#x89E3;&#x51B3;&#xFF0C;&#x591A;&#x4E2A;&#x8BF7;&#x6C42;&#x4E0B;&#x6709;&#x67D0;&#x4E2A;&#x8BF7;&#x6C42;&#x63D0;&#x524D;&#x7ED3;&#x675F;&#xFF0C;&#x5BFC;&#x81F4; loading &#x5173;&#x95ED;&#x7684;&#x95EE;&#x9898;&#x3002;</p>
<h3 id="&#x5207;&#x6362;&#x8DEF;&#x7531;&#x65F6;&#xFF0C;&#x53D6;&#x6D88;&#x4E4B;&#x524D;&#x7684;&#x8BF7;&#x6C42;">&#x5207;&#x6362;&#x8DEF;&#x7531;&#x65F6;&#xFF0C;&#x53D6;&#x6D88;&#x4E4B;&#x524D;&#x7684;&#x8BF7;&#x6C42;</h3>
<p>&#x4F7F;&#x7528; axios&#xFF0C;&#x53EF;&#x4EE5;&#x5728;&#x5207;&#x6362;&#x8DEF;&#x7531;&#x65F6;&#x628A;&#x4E4B;&#x524D;&#x6CA1;&#x5B8C;&#x6210;&#x7684;&#x8BF7;&#x6C42;&#x53D6;&#x6D88;&#x6389;&#x3002;</p>
<p>&#x5177;&#x4F53;&#x5206;&#x6790;&#x8BF7;&#x770B;&#x8FD9;&#x7BC7;&#x6587;&#x7AE0;<a href="https://juejin.im/post/6844903905625653262" target="_blank">axios&#x5207;&#x6362;&#x8DEF;&#x7531;&#x53D6;&#x6D88;&#x6307;&#x5B9A;&#x8BF7;&#x6C42;&#x4E0E;&#x53D6;&#x6D88;&#x91CD;&#x590D;&#x8BF7;&#x6C42;&#x5E76;&#x5B58;&#x65B9;&#x6848;</a>&#x3002;&#x4E0B;&#x9762;&#x5C55;&#x793A;&#x4E00;&#x4E0B;&#x5B9E;&#x73B0;&#x6548;&#x679C;&#xFF1A;</p>
<p>&#x6211;&#x65B0;&#x5EFA;&#x4E86;&#x4E00;&#x4E2A; Vue &#x9879;&#x76EE;&#xFF0C;&#x8BBE;&#x7F6E;&#x4E86; <code>a</code> <code>b</code> &#x4E24;&#x4E2A;&#x8DEF;&#x7531;&#xFF0C;&#x6BCF;&#x6B21;&#x8FDB;&#x5165;&#x8DEF;&#x7531;&#x65F6;&#xFF0C;&#x53D1;&#x8D77;&#x4E00;&#x4E2A; <code>get</code> &#x8BF7;&#x6C42;&#xFF1A;</p>
<pre><code class="lang-js">// a.vue
&lt;template&gt;
    &lt;div class=&quot;about&quot;&gt;
        &lt;h1&gt;This is an a page&lt;/h1&gt;
    &lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;
import { fetchAData } from &apos;@/api&apos;

export default {
    created() {
        fetchAData().then(res =&gt; {
            console.log(&apos;a &#x8DEF;&#x7531;&#x8BF7;&#x6C42;&#x5B8C;&#x6210;&apos;)
        })
    }
}
&lt;/script&gt;
</code></pre>
<pre><code class="lang-js">// b.vue
&lt;template&gt;
    &lt;div class=&quot;about&quot;&gt;
        &lt;h1&gt;This is an b page&lt;/h1&gt;
    &lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;
import { fetchBData } from &apos;@/api&apos;

export default {
    created() {
        fetchBData().then(res =&gt; {
            console.log(&apos;b &#x8DEF;&#x7531;&#x8BF7;&#x6C42;&#x5B8C;&#x6210;&apos;)
        })
    }
}
&lt;/script&gt;
</code></pre>
<p><img src="https://img-blog.csdnimg.cn/img_convert/302164a5f5471595af7ad29aac700b2f.gif" alt=""></p>
<p>&#x4ECE;&#x4E0A;&#x56FE;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;&#x6BCF;&#x5F53;&#x8FDB;&#x5165;&#x8DEF;&#x7531;&#x65F6;&#x4F1A;&#x53D1;&#x8D77;&#x4E00;&#x4E2A;&#x8BF7;&#x6C42;&#xFF0C;&#x8BF7;&#x6C42;&#x5B8C;&#x6210;&#x540E;&#x6253;&#x5370;&#x4E00;&#x53E5;&#x8BDD;&#x3002;&#x73B0;&#x5728;&#x6211;&#x628A;&#x7F51;&#x901F;&#x8C03;&#x4F4E;&#xFF0C;&#x7136;&#x540E;&#x6BCF;&#x6B21;&#x70B9;&#x51FB; a &#x8DEF;&#x7531;&#x65F6;&#xFF0C;&#x9A6C;&#x4E0A;&#x5C31;&#x5207;&#x6362;&#x5230; b &#x8DEF;&#x7531;&#x3002;&#x76EE;&#x7684;&#x662F;&#x4E3A;&#x4E86;&#x53D6;&#x6D88; a &#x8DEF;&#x7531;&#x9875;&#x9762;&#x7684;&#x8BF7;&#x6C42;&#xFF08;&#x9875;&#x9762;&#x4E2D;&#x7684;&#x9ED1;&#x6761;&#x5C31;&#x662F; loading &#x56FE;&#xFF09;&#x3002;</p>
<p><img src="https://img-blog.csdnimg.cn/img_convert/61e85da9d268a06324e3cad29877d5ef.png" alt=""></p>
<p><strong>&#x4E0B;&#x9762;&#x7684;&#x52A8;&#x56FE;&#x662F;&#x5B9E;&#x9A8C;&#x6548;&#x679C;&#xFF1A;</strong></p>
<p><img src="https://img-blog.csdnimg.cn/img_convert/9159dbdf44d390b68ac96ab874f76d9c.gif" alt=""></p>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;&#x6210;&#x529F;&#x53D6;&#x6D88;&#x4E86; a &#x8DEF;&#x7531;&#x9875;&#x9762;&#x7684;&#x8BF7;&#x6C42;&#x3002;</p>
<p>&#x6211;&#x628A;&#x8FD9;&#x4E2A; Vue DEMO &#x9879;&#x76EE;&#x653E;&#x4E0A; <a href="https://github.com/woai3c/toggle-router-abort-request" target="_blank">github</a> &#x4E86;&#xFF0C;&#x6709;&#x5174;&#x8DA3;&#x53EF;&#x4EE5;&#x4EB2;&#x81EA;&#x8BD5;&#x4E00;&#x4E0B;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                
                <a href="downfile.html" class="navigation navigation-next navigation-unique" aria-label="Next page: Downfile">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Control Loading","level":"1.8","depth":1,"next":{"title":"Downfile","level":"1.9","depth":1,"path":"前端进阶/downfile.md","ref":"前端进阶/downfile.md","articles":[]},"previous":{"title":"Four Operations","level":"1.7.1","depth":2,"ref":"","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["summary","livereload"],"pluginsConfig":{"summary":{},"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"前端进阶/control loading.md","mtime":"2021-02-15T12:04:36.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-03-24T08:50:55.666Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

